﻿<Code1:LoggedInPage 
    x:Class="GTasksPlus.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    xmlns:Code1="clr-namespace:GTasksPlus.Code"
    xmlns:Helpers1="clr-namespace:GTasksPlus.Helpers"
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneAccentBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="135"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0">
            <StackPanel.Resources>
                <Helpers1:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            </StackPanel.Resources>
            <CheckBox Visibility="Collapsed" IsEnabledChanged="CheckBox_IsEnabledChanged"  IsEnabled="{Binding IsDataLoaded}">
            </CheckBox>
            <toolkit:PerformanceProgressBar x:Name="performanceProgressBar" 
                                            Visibility="{Binding IsDataLoaded, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" IsIndeterminate="True" Height="5"/>
            <TextBlock x:Name="ApplicationTitle" Style="{StaticResource PhoneTextNormalStyle}" Margin="8,0">
            	<TextBlock.Foreground>
            		<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            	</TextBlock.Foreground>
            </TextBlock>
            <TextBlock x:Name="PageTitle" Text="task List" Margin="8,-7,8,0" Style="{StaticResource PhoneTextTitle1Style}">
            	<TextBlock.Foreground>
            		<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            	</TextBlock.Foreground>
            </TextBlock>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <ListBox ItemsSource="{Binding Path=Tasks}" Name="TaskListBox" >
            	<ListBox.Foreground>
            		<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            	</ListBox.Foreground>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <Button BorderThickness="0" Tag="{Binding Path=id}" Click="Button_Click" Content="{Binding Path=title}" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Width="480" Background="{StaticResource PhoneBackgroundBrush}" BorderBrush="{StaticResource PhoneBackgroundBrush}">
                            	<Button.Foreground>
                            		<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                            	</Button.Foreground>
                                <toolkit:ContextMenuService.ContextMenu>
                                    <toolkit:ContextMenu>
                                        <toolkit:MenuItem Header="Edit" Tag="{Binding Path =id}" Click="MenuItem_Click" />
                                        <toolkit:MenuItem Header="Delete" Tag="{Binding Path =id}" Click="MenuItem_Click" />
                                    </toolkit:ContextMenu>
                                </toolkit:ContextMenuService.ContextMenu>
                            </Button>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Text="Add" Click="Add_Click" IconUri="/Images/new.png"/>
            <shell:ApplicationBarIconButton Text="Refresh" Click="Refresh_Click" IconUri="/Images/refresh.png"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="About_Click" Text="About" />
                <shell:ApplicationBarMenuItem Click="Logout_Click" Text="Logout" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</Code1:LoggedInPage>